package il.ac.braude.sona.gui.forms.myforms;
import il.ac.braude.sona.constants.Resources;
import il.ac.braude.sona.gui.ButtonPanel;
import il.ac.braude.sona.gui.forms.FormFrame;
import il.ac.braude.sona.gui.forms.ReportFormPanel;
import il.ac.braude.sona.gui.forms.questions.QButton;
import il.ac.braude.sona.gui.forms.questions.QDatePicker;
import il.ac.braude.sona.gui.forms.questions.QRadioButton;

import java.awt.BorderLayout;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
/**
 * The ReportSelectForm is a FormFrame that create the gui for selecting report
 *  
 * @author Ofek Ron
 * @author Avihay Avitan
 * @author Nitzan Inbar
 * @author Sasha Rozenthal
 */
public class ReportSelectForm extends FormFrame {
	/**
	 * p - the radio button for periodic report
	 */
	private QRadioButton p;
	/**
	 * d - the radio button for delays report
	 */
	private QRadioButton d;
	/**
	 * e - the radio button for extension report
	 */
	private QRadioButton e;
	/**
	 * myButtonPanel - the panel for all buttons
	 */
	public ButtonPanel myButtonPanel;
	
	
	/**
	 * Constructs the ReportSelectForm.
	 * initiate the GUI for User
	 * 
	 * @param title -title of the form
	 * @param listener - the Reports Controller that listen to myButtonPanel
	 */
	public ReportSelectForm(String title,ActionListener listener) {
		super(title,"Submit");
		ReportFormPanel panel = new ReportFormPanel();
		panel.addTitleWithUnderline("Please select a report:");
	
		myButtonPanel = new ButtonPanel();
		myButtonPanel.setOpaque(true);
		ButtonGroup group = new ButtonGroup();
		
		p = new QRadioButton(Resources.Strings.P_report,group);
		p.set(true);
		e = new QRadioButton(Resources.Strings.E_report,group);
		d = new QRadioButton(Resources.Strings.D_report,group);
		
		myButtonPanel.add(p);
		myButtonPanel.add(e);
		myButtonPanel.add(d);
		
		panel.addQuestion(p);
		panel.addQuestion(e);
		panel.addQuestion(d);
		panel.add(myButtonPanel,BorderLayout.CENTER);
		panel.addQuestion(new QDatePicker("From: "));
		panel.addQuestion(new QDatePicker("To: "));
		panel.addQuestion(new QButton("Previous Periodic Reports",listener));
		getContentPane().add(panel,BorderLayout.NORTH);
		setFormPanel(panel);
		// TODO Auto-generated constructor stub

	}
	/**
	 * add buttons to myButtonPanel
	 * @param title - the button title
	 * @param listener - the button listener
	 */
	public void addButton(String title,ActionListener listener) {
		myButtonPanel.addButton(title, listener);
	}

}
